const getCustomNavData=function(){
	let result={};
	uni.getSystemInfo({
		success(e){
			let myStatusBar=0;
			let myCustomBar=0;
			let myNvaMartom=0;
			let myNavHeight=0;
			let myNavWidth=0;
			let custom=uni.getMenuButtonBoundingClientRect();
			myStatusBar=e.statusBarHeight;
			myNavHeight=custom.height;
			myNavWidth=custom.width;
			myNvaMartom=custom.top-e.statusBarHeight;
			myCustomBar=(myNvaMartom*2 + custom.height)- 2;
			result.statusBar=myStatusBar*750/wx.getSystemInfoSync().windowWidth;//顶部状态栏高度
			result.customBar=(myCustomBar*750/wx.getSystemInfoSync().windowWidth)+12;//导航栏高度
			result.nvaMartom=myNvaMartom*750/wx.getSystemInfoSync().windowWidth;//胶囊上边距
			result.navHeight=myNavHeight*750/wx.getSystemInfoSync().windowWidth;//胶囊按钮高度
			result.navWidth=myNavWidth*750/wx.getSystemInfoSync().windowWidth;//胶囊按钮宽度
			result.navMarRight=750-(custom.right*750/wx.getSystemInfoSync().windowWidth);//胶囊右边距
			result.pageMagTop=result.customBar+result.statusBar;//页面内容距离顶部的上边距，导航栏全部高度
		}
	})
	return result
}
const showDevelopingTips=function() {
	uni.showToast({
		title: '该功能正在研发中QWQ~',
		icon: 'none'
	})
}
const getCurrentTime=function(fields='s',separator='/',offset=0){
	const date=new Date();
	let str='';
	let y=date.getFullYear().toString();
	let m=(date.getMonth()+1).toString();
	m=m.length==1?'0'+m:m
	let d=(date.getDate()+offset).toString();
	d=d.length==1?'0'+d:d
	let h=date.getHours().toString();
	h=h.length==1?'0'+h:h
	let i=date.getMinutes().toString();
	i=i.length==1?'0'+i:i
	let s=date.getSeconds().toString();
	s=s.length==1?'0'+s:s
	if(fields=='y'){
		str=y;
	}
	if(fields=='m'){
		str=y+separator+m
	}
	if(fields=='d'){
		str=y+separator+m+separator+d
	}
	if(fields=='h'){
		str=y+separator+m+separator+d+' '+h
	}
	if(fields=='i'){
		str=y+separator+m+separator+d+' '+h+':'+i
	}
	if(fields=='s'){
		str=y+separator+m+separator+d+' '+h+':'+i+':'+s
	}
	return str;
}
const createMessageCode=function(){
	const code=createRandom(6);
	return code;
}
const createRandom=function(length=6){
	let str='';
	for(var i=0;i<length;i++){
		str+=Math.round(Math.random()*10)
	}
	return str;
}
const showToast=function(msg,callback=function(){
	
}){
	uni.showToast({
		title:msg,
		icon:'none',
		duration:2000,
		success(e){
			setTimeout(function(){
				callback()
			},2000)
		}
	})
}
export default {
	showDevelopingTips,
	getCurrentTime,
	createRandom,
	createMessageCode,
	showToast,
	getCustomNavData
}
